package com.lg.serivce;

import java.io.Serializable;
import java.sql.SQLException;
import java.util.Collection;
import java.util.List;

import com.lg.dao.Criteria;
import com.lg.dao.Example;

public interface GenericService<T extends Serializable> {
	/**
	 * ����һ�������record�ļ�¼
	 * 
	 * @param record
	 * @throws DAOException
	 * @return
	 */
	Object add(T record) throws SQLException;

	/**
	 * ����һ�������record�ļ�¼��ֻ����record��Ϊnull������
	 * 
	 * @param record
	 * @throws DAOException
	 * @return
	 */
	Object addSelective(T record) throws SQLException;

	/**
	 * ��������
	 * 
	 * @param conllection
	 * @throws DAOException
	 */
	void addBatch(Collection<T> conllection) throws SQLException;

	/**
	 * ���������¼�¼
	 * 
	 * @param record
	 * @return
	 */
	int modifyByPrimaryKey(T record) throws SQLException;

	/**
	 * ���������м�¼��ֻ����record��Ϊnull������
	 * 
	 * @param record
	 * @return
	 */
	int modifyByPrimaryKeySelective(T record) throws SQLException;

	/**
	 * ���ģ���ѯ�����ؼ���List<T>
	 * 
	 * @param example
	 * @return
	 */
	<C extends Criteria> List<T> getListByExample(Example<C> example)
			throws SQLException;

	/**
	 * ���ģ���ѯ���ӵ�star����ʼ������count����¼
	 * 
	 * @param example
	 * @param start
	 * @param count
	 * @return
	 * @throws SQLException
	 */
	<C extends Criteria> List<T> getListByExample(Example<C> example,
			int start, int count) throws SQLException;

	/**
	 * ���ģ���ѯ�����ض���T
	 * 
	 * @param example
	 * @return
	 */
	<C extends Criteria> T getObjectByExample(Example<C> example)
			throws SQLException;

	/**
	 * ��������ѯ�����ض���T
	 * 
	 * @param id
	 * @return
	 */
	T getByPrimaryKey(T id) throws SQLException;

	/**
	 * ���ģ��ɾ���ɾ��ļ�¼��
	 * 
	 * @param example
	 * @return
	 */
	<C extends Criteria> int removeByExample(Example<C> example)
			throws SQLException;

	/**
	 * �������ɾ��
	 * 
	 * @param id
	 * @return
	 */
	int removeByPrimaryKey(T id) throws SQLException;

	/**
	 * ���ģ���ѯ��Ӧ����ݼ�¼��
	 * 
	 * @param example
	 * @return
	 */
	<C extends Criteria> int countByExample(Example<C> example)
			throws SQLException;

	/**
	 * ���ģ�����record��Ϊnull���ֶΣ����ظ��¼�¼��
	 * 
	 * @param record
	 * @param example
	 * @return
	 */
	<C extends Criteria> int modifyByExampleSelective(T record,
			Example<C> example) throws SQLException;

	/**
	 * ���ģ�����,���ظ��¼�¼��
	 * 
	 * @param record
	 * @param example
	 * @return
	 */
	<C extends Criteria> int modifyByExample(T record, Example<C> example)
			throws SQLException;

	/**
	 * ���statementId(sqlmap�е�sqlId)��ѯ
	 * 
	 * @param statementId
	 * @param param
	 * @return
	 * @throws SQLException
	 */
	List<T> getListByStatementId(String statementId, Object param)
			throws SQLException;

	/**
	 * ���statementId(sqlmap�е�sqlId)��ѯ,��start��ʼ������count����¼
	 * 
	 * @param statementId
	 * @param param
	 * @param start
	 * @param count
	 * @return
	 * @throws SQLException
	 */
	List<T> getListByStatementId(String statementId, Object param, int start,
			int count) throws SQLException;

	/**
	 * ���statementId(sqlmap�е�sqlId)��ѯ
	 * 
	 * @param statementId
	 * @param param
	 * @return
	 */
	T getObjectByStatementId(String statementId, Object param)
			throws SQLException;

	/**
	 * ���statementId(sqlmap�е�sqlId)��ѯ��Ӧ����ݼ�¼��
	 * 
	 * @param example
	 * @return
	 */
	int countByStatementId(String statementId, Object param)
			throws SQLException;

	Object addByStatementId(String statementId, Object param)
			throws SQLException;

	int modifyByStatementId(String statementId, Object param)
			throws SQLException;

	int removeByStatementId(String statementId, Object param)
			throws SQLException;
}
